package com.hfzy.ihk.common.core.elasticsearch.enums;

import com.hfzy.ihk.common.facade.elasticsearch.ElasticsearchTableOperation;
import com.hfzy.ihk.common.facade.elasticsearch.entity.ElasticsearchTable;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2018/7/18.
 *
 * @author wws
 */
public enum VersionOperation implements ElasticsearchTableOperation {

    updateRedisVersion("updateRedisVersion","从es表更新版本到redis中", CommonTables.ALL),
    rollbackVersion("rollbackVersion","回滚版本", CommonTables.ALL),
    deleteVersion("deleteVersion","删除版本", CommonTables.ALL);

    private VersionOperation(String value, String desc, ElasticsearchTable belongTable){
        this.value = value;
        this.desc = desc;
        this.belongTable = belongTable;
    }

    private String value;

    private String desc;

    private ElasticsearchTable belongTable;

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }


    @Override
    public ElasticsearchTable getBelongTable() {
        return belongTable;
    }

    @Override
    public String getOperationName() {
        return value;
    }

    @Override
    public String getOperationDesc() {
        return desc;
    }

    private static Map<String, VersionOperation> map = new HashMap<String, VersionOperation>();
    static {
        for (VersionOperation value : VersionOperation.values()) {
            map.put(value.getOperationName(), value);
        }
    }

    public static VersionOperation fromValue(String value) {
        VersionOperation ret = map.get(value);
        if (ret != null) {
            return ret;
        } else {
            throw new IllegalArgumentException("No enum const " + VersionOperation.class + "." + value);
        }
    }
}
